home *** CD-ROM | disk | FTP | other *** search
- Path: the-fly.zip.com.au!not-for-mail
- From: stuartm@zip.com.au (Stuart Mackinnon)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Dynamic loading/linking
- Date: 1 Apr 1996 00:19:44 GMT
- Organization: Very Little
- Distribution: world
- Message-ID: <4jn7f0$k5f@the-fly.zip.com.au>
- References: <Dp0x52.90C.0.-s@cs.vu.nl> <4jgtg5$67h@ra.ibr.cs.tu-bs.de>
- NNTP-Posting-Host: zipper.zip.com.au
- X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
-
- Lars Duening (duening@ibr.cs.tu-bs.de) wrote:
- > In article <Dp0x52.90C.0.-s@cs.vu.nl> irmen@cs.vu.nl (Irmen de Jong) writes:
- > >Say I want to split my program into separate parts (because it's
- > >getting too big, or because some parts are rarely used).
- > >(I'm talking about my port of the python interpreter here)
- > >
- > >What solutions are feasible?
- > >
- > > [ Overlay, LoadSeg() snipped ]
- > >
- > >- Amiga shared library. Would be most ideal, but libraries cannot reference
- > > global data. (Ok Ok they can by passing all the pointers to all the
- > > global data you want to reference but in my case this is no option.
- > > Way to much global data.)
- >
- > Do it this way. With properly 'struct'ured global data, passing
- > pointers is easy (and in my experience leads to a cleaner design).
- > As an added bonus, you can run several instances of your program from
- > just one set of loaded executables.
-
- Exactly.
-
- Basically your application should have a main structure containing
- all global data. A pointer to this structure can then be passed to any
- functions within your librar[y|ies] (or functions within your executable)
- that needs the data.
-
- By doing it this way, you can then have a pointer to this type of
- structure as a "stack" variable in main(). Then allocate memory for the
- size of the structure, initialise it and then use it. Your application is
- then basically re-entrant and re-executable, and can be made residentable.
-
- If you are wanting to split it up because some parts are rarely used,
- and you do make it into shared libraries, make sure you only load the
- librar[y|ies] when you actually need them - otherwise there is not really
- much point (unless your going to run multiple copies of the app).
-
- The other advantage to shared libraries is that you can update the
- libraries independantly of the main application - for fixing bugs, adding
- more functionality etc. They also have built in version numbers which
- is very useful, and can be used by Installer to make sure the latest
- version is installed - something you can't do with separate LoadSeg()'d
- modules.
-
- I am sure there are advantages for usining LoadSeg()'d modules, or
- overlays, but there are so many more advantages with shareds libraries
- that basically there is no other choice (IMHO).
-
- Regards,
-
- Stuart MacKinnon.
- --
-
- +- Stuart MacKinnon ------------------------------------ stuartm@zip.com.au -+
- | VIC20, CBM 128+1571, A1000+Sidecar, CD32, A4000/040+A4091+A2065+RetinaZ3! |
- | Registered BeBox Developer - for those at the bleeding edge. |
- | PHONE: +61 2 398 4578 (AH) +61 2 693 0445 (BH) |
- +--- Aztec C - Use it to MANXimise code inefficiency! -----------------------+
-